import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: () => import('@/views/layout'),
    children: [
      {
        path: '', // 默认子路由
        component: () => import('@/views/home')
      },
      {
        path: '/video',
        component: () => import('@/views/video')
      },
      {
        path: '/qa',
        component: () => import('@/views/qa')
      },
      {
        path: '/profile',
        component: () => import('@/views/profile')
      }
    ]
  },
  {
    path: '/search',
    component: () => import('@/views/search')
  },
  {
    path: '/login',
    component: () => import('@/views/login') // 路由懒加载
  },
  {
    path: '/article/:articleId',
    // name: 'article',
    component: () => import('@/views/article'), // 路由懒加载
    props: true
  }
]

const router = new VueRouter({
  routes
})

export default router
